import { Component, Input, Output, EventEmitter,ViewChild } from '@angular/core';
import { Slides } from 'ionic-angular';

/**
 * Generated class for the MySlideComponent component.
 *
 * See https://angular.io/api/core/Component for more info on Angular
 * Components.
 */
@Component({
  selector: 'my-slide',
  templateUrl: 'my-slide.html'
})
export class MySlideComponent {
  @ViewChild('menuSlides') menuSlides: Slides;

  @Input("slides") slides:string[] = []; //显示类型的字符串数组
  @Input("pageNumber") pageNumber:number = 5; // pageNumber：当前屏幕可以显示的类型数目 
  @Input("selectedIndex") selectedIndex:number = 0;
  @Output("slideClick") slideClick = new EventEmitter<number>(); //当点击某个类型时，将点击的index返回给使用者
  // selectedIndex:number = 0;
  constructor() {
    console.log('Hello MySlideComponent Component');
    // this.selectedIndex = this.changeIndex;
    // this.menuSlides.slideTo(5);
    
  }
  ngOnInit() {

  }
  ngOnChanges() {
    console.log("selectIndex===="+this.selectedIndex);
    // this.menuSlides.slideTo(this.selectedIndex);
    // this.contentSlides.freeMode = true;
    
  }


  onClick(index) {
    this.selectedIndex = index;
    this.menuSlides.slideTo(this.selectedIndex);
    this.slideClick.emit(index);
  }
}
